import javax.swing.*;
import java.awt.*;

/**
 * @classname 绘制加载界面
 * @Author 姬如千泷
 * @Date 2021/5/20  0:22
 * @Version 1.0
 */
public class MyLoad extends JFrame {
    public int flag;//判断是加载城镇还是地图
    JLabel label1 = new JLabel(DateCenter.load1);
    JLabel label2 = new JLabel();
    public MyLoad(int flag){
        this.setBounds(400,100,1200,900);
        this.setResizable(false);
        this.setLayout(null);
        this.setTitle("Linの大冒险");
        this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(DateCenter.mouse, new Point(16, 16), "mycursor"));
        JLabel label = new JLabel(DateCenter.load);
        label.setBounds(0,-50,1200,900);
        label1.setBounds(0,825,1200,30);
        label2.setBounds(100,780,1200,50);
        label2.setFont(new Font("仿宋",Font.BOLD,25));
        this.add(label2);
        this.add(label1);
        this.add(label);
        this.setVisible(true);
        this.flag=flag;
        init();
    }
    public void init(){
        for (int i = 0; i < 6; i++) {
            try {
                label1.setIcon(juage(i));
                Thread.sleep(600);
                if(i==4)Thread.sleep(1000);//在一个固定帧停顿1s
                if(i%2==0)label2.setText(randomString());//每两次帧刷新生成一次提示语
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        this.dispose();
        if(flag==0) new MyFrame();
        else new MyMap(1);
    }
    public String randomString(){//随机返回一个字符串
        int i=(int)(Math.random()*5);
        switch (i){
            case 0:return "城镇的npc都特别热情，靠近他们试试看...";
            case 1:return "跳跃的时候按x会有意想不到的效果...";
            case 2:return "想要打怪的话往地图右边走走看...";
            case 3:return "冒险世界里规定技能不能连续释放...";
            case 4:return "正在打包行李...";
            default:return null;
        }
    }
    public ImageIcon juage(int t){
        switch (t){
            case 0:return DateCenter.load2;
            case 1:return DateCenter.load3;
            case 2:return DateCenter.load4;
            case 3:return DateCenter.load5;
            case 4:return DateCenter.load6;
            case 5:return DateCenter.load7;
            default:return null;
        }
    }
}
